--------------------------------------------------------------------------------
      name:  <unnamed>
       log:  R:\Current Research\Markets-Pridemore\Work\MAR02-SampDiag.log
  log type:  text
 opened on:  25 Jun 2024, 15:10:43

. 
. //  program:    Stata 
. //  task:       Sample and diagnostics 
. //  project:    Markets  
. 
. version
version 17.0

. clear all

. macro drop _all

. set linesize 80

. set more off

. local tag " 07-05-23| Cleaned 06-06-24"

. local file "MAR02-SampDiag"

. local note "|`tag' | `file'"

. local opt "noparen sideway excel noaster  bdec(2)  sdec(2)  pdec(3)   adec(2) 
> e(r2) stats(coef se pval)"

. local iv "fraser"

. local cont "infantmort  edu unemp  popdense perurban  sexratio"

. local cont2 "infantmort  gini edu unemp  popdense perurban  sexratio"

. 
. //      #0
. //      loading data 
. use MAR01-DataClean, clear 

. 
. //      #1
. //      getting sample 
. xtset CID year 

Panel variable: CID (unbalanced)
 Time variable: year, 2 to 2023, but with gaps
         Delta: 1 unit

. xtreg rhom `iv' `cont', fe 

Fixed-effects (within) regression               Number of obs     =      1,573
Group variable: CID                             Number of groups  =        100

R-squared:                                      Obs per group:
     Within  = 0.0448                                         min =          1
     Between = 0.0495                                         avg =       15.7
     Overall = 0.0594                                         max =         20

                                                F(7,1466)         =       9.82
corr(u_i, Xb) = -0.1476                         Prob > F          =     0.0000

------------------------------------------------------------------------------
        rhom | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
      fraser |  -2.447615   .3918486    -6.25   0.000    -3.216259   -1.678971
  infantmort |   .1162253   .0523536     2.22   0.027     .0135293    .2189212
         edu |  -4.456446    3.96466    -1.12   0.261    -12.23346    3.320566
       unemp |    .024499   .0435729     0.56   0.574     -.060973    .1099709
    popdense |   .0010374   .0012706     0.82   0.414     -.001455    .0035298
    perurban |   .2375225   .0664058     3.58   0.000     .1072621     .367783
    sexratio |  -.0784231   .0553602    -1.42   0.157    -.1870167    .0301704
       _cons |   17.10002   7.351933     2.33   0.020     2.678593    31.52145
-------------+----------------------------------------------------------------
     sigma_u |   8.978475
     sigma_e |  4.1268096
         rho |  .82558444   (fraction of variance due to u_i)
------------------------------------------------------------------------------
F test that all u_i=0: F(99, 1466) = 53.50                   Prob > F = 0.0000

. tab nation if e(sample)==1

                           Country Name |      Freq.     Percent        Cum.
----------------------------------------+-----------------------------------
                                Albania |         11        0.70        0.70
                              Argentina |         20        1.27        1.97
                                Armenia |         14        0.89        2.86
                              Australia |         19        1.21        4.07
                                Austria |         20        1.27        5.34
                             Azerbaijan |          2        0.13        5.47
                                Bahamas |         16        1.02        6.48
                                Bahrain |         15        0.95        7.44
                               Barbados |         14        0.89        8.33
                                Belarus |          1        0.06        8.39
                                Belgium |         19        1.21        9.60
                                 Belize |         17        1.08       10.68
                 Bosnia and Herzegovina |          1        0.06       10.74
                                 Brazil |         20        1.27       12.02
                      Brunei Darussalam |         10        0.64       12.65
                               Bulgaria |         20        1.27       13.92
                             Cabo Verde |          1        0.06       13.99
                                 Canada |         20        1.27       15.26
                                  Chile |         20        1.27       16.53
                               Colombia |         20        1.27       17.80
                             Costa Rica |         20        1.27       19.07
                                Croatia |         19        1.21       20.28
                                 Cyprus |         17        1.08       21.36
                                Czechia |         20        1.27       22.63
                                Denmark |         20        1.27       23.90
                     Dominican Republic |         19        1.21       25.11
                                Ecuador |         20        1.27       26.38
                                  Egypt |         20        1.27       27.65
                            El Salvador |         19        1.21       28.86
                                Estonia |         20        1.27       30.13
                                   Fiji |         11        0.70       30.83
                                Finland |         20        1.27       32.10
                                 France |         18        1.14       33.25
                                Georgia |         16        1.02       34.27
                                Germany |         20        1.27       35.54
                                 Greece |         20        1.27       36.81
                              Guatemala |         20        1.27       38.08
                                 Guyana |         19        1.21       39.29
                                Hungary |         20        1.27       40.56
                                Iceland |         20        1.27       41.83
             Iran (Islamic Republic of) |          4        0.25       42.09
                                   Iraq |          1        0.06       42.15
                                Ireland |         17        1.08       43.23
                                 Israel |         20        1.27       44.50
                                  Italy |         20        1.27       45.77
                                Jamaica |         13        0.83       46.60
                                  Japan |         20        1.27       47.87
                                 Jordan |          9        0.57       48.44
                             Kazakhstan |         15        0.95       49.40
                                 Kuwait |         20        1.27       50.67
                             Kyrgyzstan |         15        0.95       51.62
                                 Latvia |         20        1.27       52.89
                                Lebanon |          1        0.06       52.96
                              Lithuania |         20        1.27       54.23
                             Luxembourg |         20        1.27       55.50
                               Malaysia |         20        1.27       56.77
                                  Malta |         18        1.14       57.91
                              Mauritius |         20        1.27       59.19
                                 Mexico |         20        1.27       60.46
                               Mongolia |          4        0.25       60.71
                             Montenegro |          6        0.38       61.09
                            Netherlands |         20        1.27       62.36
                            New Zealand |         17        1.08       63.45
                              Nicaragua |         15        0.95       64.40
                        North Macedonia |         16        1.02       65.42
                                 Norway |         17        1.08       66.50
                                   Oman |          7        0.45       66.94
                                 Panama |         20        1.27       68.21
                               Paraguay |         20        1.27       69.49
                                   Peru |         20        1.27       70.76
                            Philippines |         15        0.95       71.71
                                 Poland |         20        1.27       72.98
                               Portugal |         17        1.08       74.06
                                  Qatar |          9        0.57       74.63
                      Republic of Korea |         20        1.27       75.91
                    Republic of Moldova |         14        0.89       76.80
                                Romania |         20        1.27       78.07
                     Russian Federation |         20        1.27       79.34
                                 Serbia |         15        0.95       80.29
                             Seychelles |          5        0.32       80.61
                              Singapore |         20        1.27       81.88
                               Slovakia |         16        1.02       82.90
                               Slovenia |         20        1.27       84.17
                           South Africa |         19        1.21       85.38
                                  Spain |         20        1.27       86.65
                              Sri Lanka |         14        0.89       87.54
                               Suriname |          5        0.32       87.86
                                 Sweden |         19        1.21       89.07
                            Switzerland |         20        1.27       90.34
                   Syrian Arab Republic |         11        0.70       91.04
                             Tajikistan |          2        0.13       91.16
                               Thailand |         19        1.21       92.37
                    Trinidad and Tobago |         13        0.83       93.20
                                 Turkey |         11        0.70       93.90
                                Ukraine |         18        1.14       95.04
                   United Arab Emirates |          2        0.13       95.17
United Kingdom of Great Britain and N.. |         20        1.27       96.44
               United States of America |         20        1.27       97.71
                                Uruguay |         19        1.21       98.92
     Venezuela (Bolivarian Republic of) |         17        1.08      100.00
----------------------------------------+-----------------------------------
                                  Total |      1,573      100.00

. gen sample=1 if e(sample)==1 
(21,083 missing values generated)

. /* Nations to drop 
> Azerbaijan
> Belarus
> Bosnia and Herzegovina
> Cabo Verde
> Iran (Islamic Republic of)
> Iraq
> Lebanon
> Mongolia
> Seychelles
> Suriname
> Tajikistan
> United Arab Emirates
> */ 
. replace sample=. if nation=="Azerbaijan"
(2 real changes made, 2 to missing)

. replace sample=. if nation=="Belarus"
(1 real change made, 1 to missing)

. replace sample=. if nation=="Bosnia and Herzegovina"
(1 real change made, 1 to missing)

. replace sample=. if nation=="Cabo Verde"
(1 real change made, 1 to missing)

. replace sample=. if nation=="Iran (Islamic Republic of)"
(4 real changes made, 4 to missing)

. replace sample=. if nation=="Iraq"
(1 real change made, 1 to missing)

. replace sample=. if nation=="Lebanon"
(1 real change made, 1 to missing)

. replace sample=. if nation=="Mongolia"
(4 real changes made, 4 to missing)

. replace sample=. if nation=="Seychelles"
(5 real changes made, 5 to missing)

. replace sample=. if nation=="Suriname"
(5 real changes made, 5 to missing)

. replace sample=. if nation=="Tajikistan"
(2 real changes made, 2 to missing)

. replace sample=. if nation=="United Arab Emirates"
(2 real changes made, 2 to missing)

. 
. tab nation if rhom==0

                           Country Name |      Freq.     Percent        Cum.
----------------------------------------+-----------------------------------
                                Albania |          3        2.44        2.44
                    Antigua and Barbuda |         23       18.70       21.14
                                Bahrain |          8        6.50       27.64
                               Barbados |          1        0.81       28.46
                                 Belize |         19       15.45       43.90
                      Brunei Darussalam |          5        4.07       47.97
                                 Cyprus |          1        0.81       48.78
                          French Guiana |          4        3.25       52.03
                                Grenada |         11        8.94       60.98
                                Iceland |         16       13.01       73.98
                               Maldives |          5        4.07       78.05
                                  Malta |         10        8.13       86.18
                             Martinique |          1        0.81       86.99
                                Mayotte |          2        1.63       88.62
                                   Oman |          1        0.81       89.43
                                  Qatar |          1        0.81       90.24
                            Saint Lucia |          6        4.88       95.12
       Saint Vincent and the Grenadines |          6        4.88      100.00
----------------------------------------+-----------------------------------
                                  Total |        123      100.00

. replace sample=. if rhom==0
(20 real changes made, 20 to missing)

. 
. tab nation if sample==1

                           Country Name |      Freq.     Percent        Cum.
----------------------------------------+-----------------------------------
                                Albania |          8        0.52        0.52
                              Argentina |         20        1.31        1.84
                                Armenia |         14        0.92        2.76
                              Australia |         19        1.25        4.00
                                Austria |         20        1.31        5.31
                                Bahamas |         16        1.05        6.36
                                Bahrain |          7        0.46        6.82
                               Barbados |         13        0.85        7.68
                                Belgium |         19        1.25        8.92
                                 Belize |         17        1.12       10.04
                                 Brazil |         20        1.31       11.35
                      Brunei Darussalam |          7        0.46       11.81
                               Bulgaria |         20        1.31       13.12
                                 Canada |         20        1.31       14.44
                                  Chile |         20        1.31       15.75
                               Colombia |         20        1.31       17.06
                             Costa Rica |         20        1.31       18.37
                                Croatia |         19        1.25       19.62
                                 Cyprus |         17        1.12       20.73
                                Czechia |         20        1.31       22.05
                                Denmark |         20        1.31       23.36
                     Dominican Republic |         19        1.25       24.61
                                Ecuador |         20        1.31       25.92
                                  Egypt |         20        1.31       27.23
                            El Salvador |         19        1.25       28.48
                                Estonia |         20        1.31       29.79
                                   Fiji |         11        0.72       30.51
                                Finland |         20        1.31       31.82
                                 France |         18        1.18       33.01
                                Georgia |         16        1.05       34.06
                                Germany |         20        1.31       35.37
                                 Greece |         20        1.31       36.68
                              Guatemala |         20        1.31       37.99
                                 Guyana |         19        1.25       39.24
                                Hungary |         20        1.31       40.55
                                Iceland |         18        1.18       41.73
                                Ireland |         17        1.12       42.85
                                 Israel |         20        1.31       44.16
                                  Italy |         20        1.31       45.47
                                Jamaica |         13        0.85       46.33
                                  Japan |         20        1.31       47.64
                                 Jordan |          9        0.59       48.23
                             Kazakhstan |         15        0.98       49.21
                                 Kuwait |         20        1.31       50.52
                             Kyrgyzstan |         15        0.98       51.51
                                 Latvia |         20        1.31       52.82
                              Lithuania |         20        1.31       54.13
                             Luxembourg |         20        1.31       55.45
                               Malaysia |         20        1.31       56.76
                                  Malta |         16        1.05       57.81
                              Mauritius |         20        1.31       59.12
                                 Mexico |         20        1.31       60.43
                             Montenegro |          6        0.39       60.83
                            Netherlands |         20        1.31       62.14
                            New Zealand |         17        1.12       63.25
                              Nicaragua |         15        0.98       64.24
                        North Macedonia |         16        1.05       65.29
                                 Norway |         17        1.12       66.40
                                   Oman |          6        0.39       66.80
                                 Panama |         20        1.31       68.11
                               Paraguay |         20        1.31       69.42
                                   Peru |         20        1.31       70.73
                            Philippines |         15        0.98       71.72
                                 Poland |         20        1.31       73.03
                               Portugal |         17        1.12       74.15
                                  Qatar |          9        0.59       74.74
                      Republic of Korea |         20        1.31       76.05
                    Republic of Moldova |         14        0.92       76.97
                                Romania |         20        1.31       78.28
                     Russian Federation |         20        1.31       79.59
                                 Serbia |         15        0.98       80.58
                              Singapore |         20        1.31       81.89
                               Slovakia |         16        1.05       82.94
                               Slovenia |         20        1.31       84.25
                           South Africa |         19        1.25       85.50
                                  Spain |         20        1.31       86.81
                              Sri Lanka |         14        0.92       87.73
                                 Sweden |         19        1.25       88.98
                            Switzerland |         20        1.31       90.29
                   Syrian Arab Republic |         11        0.72       91.01
                               Thailand |         19        1.25       92.26
                    Trinidad and Tobago |         13        0.85       93.11
                                 Turkey |         11        0.72       93.83
                                Ukraine |         18        1.18       95.01
United Kingdom of Great Britain and N.. |         20        1.31       96.33
               United States of America |         20        1.31       97.64
                                Uruguay |         19        1.25       98.88
     Venezuela (Bolivarian Republic of) |         17        1.12      100.00
----------------------------------------+-----------------------------------
                                  Total |      1,524      100.00

. drop if sample!=1
(21,132 observations deleted)

. 
. //      #2
. //      normal 
. * qladder rhom 
. gen lrhom=log(rhom) 

. label var lrhom "Ln Homicide Victimization Rates" 

. note lrhom: `note'. 

. 
. //      #3
. //      station 
. xtunitroot fisher rhom, dfuller lags(0) 

Fisher-type unit-root test for rhom
Based on augmented Dickey–Fuller tests
--------------------------------------
H0: All panels contain unit roots           Number of panels       =     88
Ha: At least one panel is stationary        Avg. number of periods =  17.32

AR parameter: Panel-specific                Asymptotics: T -> Infinity
Panel means:  Included
Time trend:   Not included
Drift term:   Not included                  ADF regressions: 0 lags
------------------------------------------------------------------------------
                                  Statistic      p-value
------------------------------------------------------------------------------
 Inverse chi-squared(176)  P       301.8661       0.0000
 Inverse normal            Z        -2.8590       0.0021
 Inverse logit t(434)      L*       -3.8666       0.0001
 Modified inv. chi-squared Pm        6.7087       0.0000
------------------------------------------------------------------------------
 P statistic requires number of panels to be finite.
 Other statistics are suitable for finite or infinite number of panels.
------------------------------------------------------------------------------

. 
. foreach var in `iv' `cont'  {
  2.         xtunitroot fisher `var', dfuller lags(0) 
  3.         }

Fisher-type unit-root test for fraser
Based on augmented Dickey–Fuller tests
--------------------------------------
H0: All panels contain unit roots           Number of panels       =     88
Ha: At least one panel is stationary        Avg. number of periods =  17.32

AR parameter: Panel-specific                Asymptotics: T -> Infinity
Panel means:  Included
Time trend:   Not included
Drift term:   Not included                  ADF regressions: 0 lags
------------------------------------------------------------------------------
                                  Statistic      p-value
------------------------------------------------------------------------------
 Inverse chi-squared(176)  P       359.6275       0.0000
 Inverse normal            Z        -4.9944       0.0000
 Inverse logit t(434)      L*       -6.6188       0.0000
 Modified inv. chi-squared Pm        9.7874       0.0000
------------------------------------------------------------------------------
 P statistic requires number of panels to be finite.
 Other statistics are suitable for finite or infinite number of panels.
------------------------------------------------------------------------------

Fisher-type unit-root test for infantmort
Based on augmented Dickey–Fuller tests
-----------------------------------------
H0: All panels contain unit roots           Number of panels       =     88
Ha: At least one panel is stationary        Avg. number of periods =  17.32

AR parameter: Panel-specific                Asymptotics: T -> Infinity
Panel means:  Included
Time trend:   Not included
Drift term:   Not included                  ADF regressions: 0 lags
------------------------------------------------------------------------------
                                  Statistic      p-value
------------------------------------------------------------------------------
 Inverse chi-squared(176)  P      2070.8045       0.0000
 Inverse normal            Z       -26.7255       0.0000
 Inverse logit t(419)      L*      -58.0529       0.0000
 Modified inv. chi-squared Pm      100.9934       0.0000
------------------------------------------------------------------------------
 P statistic requires number of panels to be finite.
 Other statistics are suitable for finite or infinite number of panels.
------------------------------------------------------------------------------

Fisher-type unit-root test for edu
Based on augmented Dickey–Fuller tests
--------------------------------------
H0: All panels contain unit roots           Number of panels       =     88
Ha: At least one panel is stationary        Avg. number of periods =  17.32

AR parameter: Panel-specific                Asymptotics: T -> Infinity
Panel means:  Included
Time trend:   Not included
Drift term:   Not included                  ADF regressions: 0 lags
------------------------------------------------------------------------------
                                  Statistic      p-value
------------------------------------------------------------------------------
 Inverse chi-squared(176)  P       402.4970       0.0000
 Inverse normal            Z        -2.0467       0.0203
 Inverse logit t(429)      L*       -5.6770       0.0000
 Modified inv. chi-squared Pm       12.0723       0.0000
------------------------------------------------------------------------------
 P statistic requires number of panels to be finite.
 Other statistics are suitable for finite or infinite number of panels.
------------------------------------------------------------------------------

Fisher-type unit-root test for unemp
Based on augmented Dickey–Fuller tests
--------------------------------------
H0: All panels contain unit roots           Number of panels       =     88
Ha: At least one panel is stationary        Avg. number of periods =  17.32

AR parameter: Panel-specific                Asymptotics: T -> Infinity
Panel means:  Included
Time trend:   Not included
Drift term:   Not included                  ADF regressions: 0 lags
------------------------------------------------------------------------------
                                  Statistic      p-value
------------------------------------------------------------------------------
 Inverse chi-squared(176)  P       228.8276       0.0045
 Inverse normal            Z         0.8447       0.8009
 Inverse logit t(429)      L*       -0.7460       0.2280
 Modified inv. chi-squared Pm        2.8157       0.0024
------------------------------------------------------------------------------
 P statistic requires number of panels to be finite.
 Other statistics are suitable for finite or infinite number of panels.
------------------------------------------------------------------------------

Fisher-type unit-root test for popdense
Based on augmented Dickey–Fuller tests
---------------------------------------
H0: All panels contain unit roots           Number of panels       =     88
Ha: At least one panel is stationary        Avg. number of periods =  17.32

AR parameter: Panel-specific                Asymptotics: T -> Infinity
Panel means:  Included
Time trend:   Not included
Drift term:   Not included                  ADF regressions: 0 lags
------------------------------------------------------------------------------
                                  Statistic      p-value
------------------------------------------------------------------------------
 Inverse chi-squared(176)  P       797.1440       0.0000
 Inverse normal            Z        -5.4764       0.0000
 Inverse logit t(334)      L*      -17.4498       0.0000
 Modified inv. chi-squared Pm       33.1071       0.0000
------------------------------------------------------------------------------
 P statistic requires number of panels to be finite.
 Other statistics are suitable for finite or infinite number of panels.
------------------------------------------------------------------------------

Fisher-type unit-root test for perurban
Based on augmented Dickey–Fuller tests
---------------------------------------
H0: All panels contain unit roots           Number of panels       =     88
Ha: At least one panel is stationary        Avg. number of periods =  17.32

AR parameter: Panel-specific                Asymptotics: T -> Infinity
Panel means:  Included
Time trend:   Not included
Drift term:   Not included                  ADF regressions: 0 lags
------------------------------------------------------------------------------
                                  Statistic      p-value
------------------------------------------------------------------------------
 Inverse chi-squared(176)  P      1695.0710       0.0000
 Inverse normal            Z       -20.9775       0.0000
 Inverse logit t(344)      L*      -50.2316       0.0000
 Modified inv. chi-squared Pm       80.9668       0.0000
------------------------------------------------------------------------------
 P statistic requires number of panels to be finite.
 Other statistics are suitable for finite or infinite number of panels.
------------------------------------------------------------------------------

Fisher-type unit-root test for sexratio
Based on augmented Dickey–Fuller tests
---------------------------------------
H0: All panels contain unit roots           Number of panels       =     88
Ha: At least one panel is stationary        Avg. number of periods =  17.32

AR parameter: Panel-specific                Asymptotics: T -> Infinity
Panel means:  Included
Time trend:   Not included
Drift term:   Not included                  ADF regressions: 0 lags
------------------------------------------------------------------------------
                                  Statistic      p-value
------------------------------------------------------------------------------
 Inverse chi-squared(176)  P       681.3269       0.0000
 Inverse normal            Z        -4.3198       0.0000
 Inverse logit t(364)      L*      -13.4723       0.0000
 Modified inv. chi-squared Pm       26.9340       0.0000
------------------------------------------------------------------------------
 P statistic requires number of panels to be finite.
 Other statistics are suitable for finite or infinite number of panels.
------------------------------------------------------------------------------

.         
. //      #4
. //  Autocorrelation 
. xtserial rhom `iv' `cont'

Wooldridge test for autocorrelation in panel data
H0: no first order autocorrelation
    F(  1,      86) =      0.246
           Prob > F =      0.6211

. xtserial lrhom `iv' `cont'

Wooldridge test for autocorrelation in panel data
H0: no first order autocorrelation
    F(  1,      86) =      0.118
           Prob > F =      0.7325

. xtserial lrhom `iv' `cont2'

Wooldridge test for autocorrelation in panel data
H0: no first order autocorrelation
    F(  1,      69) =      0.000
           Prob > F =      0.9925

. xtserial rhom `iv' `cont2'

Wooldridge test for autocorrelation in panel data
H0: no first order autocorrelation
    F(  1,      69) =      0.124
           Prob > F =      0.7253

. 
. //      #5
. //      Cross-Sectional Dependence 
. xtreg rhom `iv' `cont' , fe

Fixed-effects (within) regression               Number of obs     =      1,524
Group variable: CID                             Number of groups  =         88

R-squared:                                      Obs per group:
     Within  = 0.0454                                         min =          6
     Between = 0.0635                                         avg =       17.3
     Overall = 0.0633                                         max =         20

                                                F(7,1429)         =       9.70
corr(u_i, Xb) = -0.1399                         Prob > F          =     0.0000

------------------------------------------------------------------------------
        rhom | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
      fraser |  -2.503179   .3998297    -6.26   0.000    -3.287495   -1.718863
  infantmort |   .1146283   .0532568     2.15   0.032     .0101584    .2190983
         edu |  -4.168589   4.038326    -1.03   0.302    -12.09027    3.753094
       unemp |   .0234132   .0441739     0.53   0.596    -.0632393    .1100658
    popdense |   .0009818   .0012904     0.76   0.447    -.0015495    .0035132
    perurban |   .2385706   .0673295     3.54   0.000     .1064954    .3706458
    sexratio |  -.0919525   .0610448    -1.51   0.132    -.2116995    .0277945
       _cons |   18.74726   7.788442     2.41   0.016     3.469258    34.02527
-------------+----------------------------------------------------------------
     sigma_u |  9.2859109
     sigma_e |  4.1643395
         rho |  .83256014   (fraction of variance due to u_i)
------------------------------------------------------------------------------
F test that all u_i=0: F(87, 1429) = 57.88                   Prob > F = 0.0000

. * xtcsd, pesaran abs
. xtreg lrhom `iv' `cont2' , fe

Fixed-effects (within) regression               Number of obs     =      1,219
Group variable: CID                             Number of groups  =         84

R-squared:                                      Obs per group:
     Within  = 0.1853                                         min =          1
     Between = 0.1911                                         avg =       14.5
     Overall = 0.3048                                         max =         20

                                                F(8,1127)         =      32.04
corr(u_i, Xb) = 0.2049                          Prob > F          =     0.0000

------------------------------------------------------------------------------
       lrhom | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
      fraser |  -.2325844   .0419928    -5.54   0.000    -.3149773   -.1501914
  infantmort |   .0208439   .0059115     3.53   0.000     .0092452    .0324427
        gini |  -.0169971   .0051991    -3.27   0.001    -.0271981   -.0067962
         edu |  -3.225835   .4163851    -7.75   0.000    -4.042812   -2.408858
       unemp |   .0054593   .0042838     1.27   0.203    -.0029458    .0138644
    popdense |  -.0000702   .0002682    -0.26   0.794    -.0005965    .0004561
    perurban |   .0245056   .0067693     3.62   0.000     .0112238    .0377875
    sexratio |  -.0313256   .0086445    -3.62   0.000    -.0482866   -.0143646
       _cons |   6.693501   .9659054     6.93   0.000     4.798326    8.588676
-------------+----------------------------------------------------------------
     sigma_u |  1.2102319
     sigma_e |  .36979625
         rho |  .91460699   (fraction of variance due to u_i)
------------------------------------------------------------------------------
F test that all u_i=0: F(83, 1127) = 68.34                   Prob > F = 0.0000

. * xtcsd, pesaran abs
. 
. /* Neither had enough obs */ 
. 
. //      #6
. //      Homoscedastic 
. xtreg rhom `iv' `cont' , fe

Fixed-effects (within) regression               Number of obs     =      1,524
Group variable: CID                             Number of groups  =         88

R-squared:                                      Obs per group:
     Within  = 0.0454                                         min =          6
     Between = 0.0635                                         avg =       17.3
     Overall = 0.0633                                         max =         20

                                                F(7,1429)         =       9.70
corr(u_i, Xb) = -0.1399                         Prob > F          =     0.0000

------------------------------------------------------------------------------
        rhom | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
      fraser |  -2.503179   .3998297    -6.26   0.000    -3.287495   -1.718863
  infantmort |   .1146283   .0532568     2.15   0.032     .0101584    .2190983
         edu |  -4.168589   4.038326    -1.03   0.302    -12.09027    3.753094
       unemp |   .0234132   .0441739     0.53   0.596    -.0632393    .1100658
    popdense |   .0009818   .0012904     0.76   0.447    -.0015495    .0035132
    perurban |   .2385706   .0673295     3.54   0.000     .1064954    .3706458
    sexratio |  -.0919525   .0610448    -1.51   0.132    -.2116995    .0277945
       _cons |   18.74726   7.788442     2.41   0.016     3.469258    34.02527
-------------+----------------------------------------------------------------
     sigma_u |  9.2859109
     sigma_e |  4.1643395
         rho |  .83256014   (fraction of variance due to u_i)
------------------------------------------------------------------------------
F test that all u_i=0: F(87, 1429) = 57.88                   Prob > F = 0.0000

. xttest3 

Modified Wald test for groupwise heteroskedasticity
in fixed effect regression model

H0: sigma(i)^2 = sigma^2 for all i

chi2 (88)  =    7.5e+06
Prob>chi2 =      0.0000


. 
. xtreg lrhom `iv' `cont' , fe

Fixed-effects (within) regression               Number of obs     =      1,524
Group variable: CID                             Number of groups  =         88

R-squared:                                      Obs per group:
     Within  = 0.1294                                         min =          6
     Between = 0.3310                                         avg =       17.3
     Overall = 0.3199                                         max =         20

                                                F(7,1429)         =      30.33
corr(u_i, Xb) = 0.2209                          Prob > F          =     0.0000

------------------------------------------------------------------------------
       lrhom | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
      fraser |  -.2445491   .0394059    -6.21   0.000    -.3218487   -.1672495
  infantmort |   .0044805   .0052488     0.85   0.393    -.0058158    .0147767
         edu |   -2.72643    .398004    -6.85   0.000    -3.507165   -1.945695
       unemp |   .0035128   .0043536     0.81   0.420    -.0050274     .012053
    popdense |  -.0003394   .0001272    -2.67   0.008    -.0005889   -.0000899
    perurban |   .0094687   .0066358     1.43   0.154    -.0035482    .0224856
    sexratio |  -.0122216   .0060164    -2.03   0.042    -.0240235   -.0004197
       _cons |   5.264567   .7676031     6.86   0.000     3.758818    6.770317
-------------+----------------------------------------------------------------
     sigma_u |  1.1500481
     sigma_e |  .41042354
         rho |  .88702822   (fraction of variance due to u_i)
------------------------------------------------------------------------------
F test that all u_i=0: F(87, 1429) = 102.16                  Prob > F = 0.0000

. xttest3 

Modified Wald test for groupwise heteroskedasticity
in fixed effect regression model

H0: sigma(i)^2 = sigma^2 for all i

chi2 (88)  =   20626.32
Prob>chi2 =      0.0000


. 
. //      #7
. //      Final model 
. xtreg rhom `iv' `cont', fe vce(robust) 

Fixed-effects (within) regression               Number of obs     =      1,524
Group variable: CID                             Number of groups  =         88

R-squared:                                      Obs per group:
     Within  = 0.0454                                         min =          6
     Between = 0.0635                                         avg =       17.3
     Overall = 0.0633                                         max =         20

                                                F(7,87)           =       2.09
corr(u_i, Xb) = -0.1399                         Prob > F          =     0.0529

                                   (Std. err. adjusted for 88 clusters in CID)
------------------------------------------------------------------------------
             |               Robust
        rhom | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
      fraser |  -2.503179   .9513973    -2.63   0.010    -4.394184   -.6121739
  infantmort |   .1146283    .104389     1.10   0.275    -.0928561    .3221127
         edu |  -4.168589   8.229851    -0.51   0.614    -20.52631    12.18913
       unemp |   .0234132   .1000287     0.23   0.815    -.1754047    .2222312
    popdense |   .0009818   .0009103     1.08   0.284    -.0008275    .0027911
    perurban |   .2385706   .1750912     1.36   0.177    -.1094422    .5865833
    sexratio |  -.0919525   .0590468    -1.56   0.123    -.2093144    .0254094
       _cons |   18.74726   14.36999     1.30   0.195    -9.814644    47.30917
-------------+----------------------------------------------------------------
     sigma_u |  9.2859109
     sigma_e |  4.1643395
         rho |  .83256014   (fraction of variance due to u_i)
------------------------------------------------------------------------------

. outreg2 using `file', replace `opt' 
MAR02-SampDiag.xml
dir : seeout

. 
. //      #8
. //      save and close 
. note:  Completed sample and pre-model diagnostics | `note'. 

. notes

_dta:
  1.  Cleaned WHO homicide data for overall, age and gender | merged data
      together | |meg | 03-23-2023 | CT01-DataMerge-V02.
  2.  30JUN2022
  3.  Got data out of .csv into .dta, merged data, and generated variables | \
      06-28-2022 \ SP01-CleaningData.
  4.  Completed sample and pre-model diagnostics | | 07-05-23| Cleaned 06-06-24
      | MAR02-SampDiag.

ryoung:
  1.  (pop1519*1000)+(pop2024*1000)/pop *100

rmyoung:
  1.  (mpop1519*1000)+(mpop2024*1000)+(mpop2529*1000)/popmale*100 | \ 06-28-2022
      \ SP01-CleaningData.

edu:
  1.  (eys_index+mys_index)/2 | \ 06-28-2022 \ SP01-CleaningData.

unemp:
  1.  Nation Estimates then missing filled with ILO estimates corr 1 or .9457 |
      \ 06-28-2022 \ SP01-CleaningData.

sexratio:
  1.  popmale/popfemale*100 | \ 06-28-2022 \ SP01-CleaningData.

eys_index:
  1.  (eys-0)/(18+0) | \ 06-28-2022 \ SP01-CleaningData

mys_index:
  1.  (mys-0)/(15+0) | \ 06-28-2022 \ SP01-CleaningData

lrhom:
  1.  | 07-05-23| Cleaned 06-06-24 | MAR02-SampDiag.

. save `file'.dta, replace 
file MAR02-SampDiag.dta saved

. log close 
      name:  <unnamed>
       log:  R:\Current Research\Markets-Pridemore\Work\MAR02-SampDiag.log
  log type:  text
 closed on:  25 Jun 2024, 15:10:52
--------------------------------------------------------------------------------
